
#include "crc.h"


unsigned char crc8(unsigned char crc, unsigned char data)
{
  crc = crc ^ data;
  for (int i = 0; i < 8; i++) {
    if (crc & 0x01)
      crc = (crc >> 1) ^ 0x8C;
    else
      crc >>= 1;
  }
  return crc;
}

